package com.ftg.learn.rbac.mapper;

import com.ftg.learn.rbac.entity.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author kangjx
 * @since 2022-03-23
 */
@Mapper
public interface RoleMapper extends BaseMapper<Role> {

    @Update("update sys_role set rstatus=#{num} where rid = #{id}")
    int updateForUstatus(@Param("id") int id, @Param("num") int num);

    @Select("select rid from sys_user_role where uid = #{uid}")
    List<String> showRoleIdForUid(@Param("uid") String uid);

    @Delete("delete from sys_user_role where uid = #{uid}")
    void deleteUserRole(int uid);

    @Insert("insert into sys_user_role(uid,rid) values(#{uid},#{rid})")
    void saveUserRole(@Param("uid") int uid,@Param("rid") String rid);

}
